using System;
using System.Windows.Forms.Design;
using VSSDKAssist.Assets.Actions.Base;

namespace VSSDKAssist.Assets.Actions.General
{
	/// <summary>
	/// Action that displays a message to the user
	/// </summary>
	public class DisplayMessageAction : ActionBase
	{
		#region Constants
		private const string Message = "Message";
		#endregion

		#region Fields		
		private string message; 
		#endregion

		/// <summary>
		/// Called when [execute].
		/// </summary>
		protected override void OnExecute()
		{
			IUIService uiService = GetService<IUIService>(true);

			uiService.ShowMessage(this.message);
		}

		/// <summary>
		/// Called when [configure].
		/// </summary>
		/// <param name="attributes">The attributes.</param>
		protected override void OnConfigure(System.Collections.Specialized.StringDictionary attributes)
		{
			if(attributes == null)
				throw new ArgumentNullException("attributes");

			if(attributes.ContainsKey(Message))
			{
				message = attributes[Message];
			}
		}
	}
}